module example3
    use ISO_C_binding
    use example1
    use example2
    implicit none
    public :: mainn
    type mainn

      type(c_ptr), pointer :: part3d_in 
      class(simulation), pointer :: pd => null()
      ! integer(c_int) :: dim1,dim2
      integer(c_int) :: dim

      contains

      generic :: new => init
      generic :: del => end
      generic :: go3 => go
      procedure, private :: go
      procedure, private :: init, end
   
  end type mainn

  contains
  
  subroutine init(this)
    implicit none
    class(mainn), intent(inout) :: this
   
      allocate(this%pd)
      allocate(this%part3d_in)

  end subroutine init
  
  ! subroutine go(this,part3d_in,dim1,dim2)
  subroutine go(this,part3d_in,dim)
    implicit none
    class(mainn), intent(inout) :: this
    ! integer(c_int), intent(inout) :: dim1,dim2
    integer(c_int), intent(in) :: dim
    type(c_ptr), value, intent(in) :: part3d_in

          call this%new()
          this%part3d_in = part3d_in
          ! this%dim1 = dim1
          ! this%dim2 = dim2
          this%dim = dim
          ! call this%pd%go2(part3d_in,dim1,dim2)
          call this%pd%go2(part3d_in,dim)
          call this%del()
    
  end subroutine go
      
  subroutine end(this)
    implicit none
    class(mainn), intent(inout) :: this

      deallocate(this%pd)
      deallocate(this%part3d_in)

  end subroutine end
end module example3